package Lian02;

import java.util.Arrays;
import java.util.Scanner;

/**
 * 插入排序
 */
public class ChaRuShuZu {
    public static void main(String[] args) {
//        有一组学员的成绩{99,85,82,63,60},
//        将他们按照降序排列。要增加一个学员的成绩，将它插入降序排列，并保持降序
        int[]  scores = {99,85,82,63,60};
        System.out.println("请输入你的成绩");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        int index =scores.length ;
        for (int i = 0; i < scores.length; i++) {
            if (num>scores[i]){
                index = i;
                break;
            }
        }
        System.out.println(index);
        int[] arrInt = Arrays.copyOf(scores,scores.length+1);
        System.out.println(Arrays.toString(arrInt));

        for (int i = arrInt.length-1; i >index; i--) {
            arrInt[i] = arrInt[i-1];
        }
        System.out.println(Arrays.toString(arrInt));
        arrInt[index] = num;
        System.out.println(Arrays.toString(arrInt));
    }
}
